package info.webest.reminder;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class Options {

	public enum ScreenTheme {
		THEME_BLACK, THEME_LIGHT
	};

	public static final String THEME = "Theme";
	public static final String REFRESH_UI = "RefreshUI";
	public static final String SHOW_WIDGET_BACKGROUND = "ShowWidgetBackground";

	public static final String ACCOUNT_NAME = "AccountName";
	public static final String ACCOUNT_TYPE = "AccountType";

	public static final String WIDGET_ITEM_COUNT_PORTRAIT = "WidgetItemCountPortrait";
	public static final String WIDGET_ITEM_COUNT_LANDSCAPE = "WidgetItemCountLandscape";

	public static final String NOTIFICATION_ENABLE = "NotificationEnable";
	public static final String NOTIFICATION_PLAY_SOUND = "NotificationPlaySound";
	public static final String NOTIFICATION_VIBRATE = "NotificationVibrate";
	public static final String NOTIFICATION_SHOW_LIGHT = "NotificationShowLight";
	public static final String NOTIFICATION_AUTO_CANCEL = "NotificationAutoCancel";
	public static final String NOTIFICATION_NO_CLEAR = "NotificationNoClear";

	public static ScreenTheme Theme = ScreenTheme.THEME_BLACK;
	public static String sBlackTheme = "Black";
	public static String sLightTheme = "Light";
	static boolean showWidgetBackground = false;

	static int widgetItemSize = 75;

	static int themeId = 1;

	static int WidgetItemCountPortrait = 4;
	static int WidgetItemCountLandscape = 10;

	static boolean nEnable = true;
	static boolean nPlaySound = true;
	static boolean nVibrate = false;
	static boolean nShowLight = false;
	static boolean nAutoCancel = true;
	static boolean nNoClear = true;

	// WidgetItemCountPortrait
	public static int getWidgetItemCountPortrait() {
		return WidgetItemCountPortrait;
	}

	public static void setWidgetItemCountPortrait(int value) {
		WidgetItemCountPortrait = value;
	}

	// WidgetItemCountLandscape
	public static int getWidgetItemCountLandscape() {
		return WidgetItemCountLandscape;
	}

	public static void setWidgetItemCountLandscape(int value) {
		WidgetItemCountLandscape = value;
	}

	// widgetItemSize
	public static int getWidgetItemSize() {
		return widgetItemSize;
	}

	public static void setWidgetItemSize(int value) {
		widgetItemSize = value;
	}

	// Notification Enable
	public static boolean getNotificationEnable() {
		return nEnable;
	}

	public static void setNotificationEnable(boolean value) {
		nEnable = value;
	}

	// Notification Play Sound
	public static boolean getNotificationPlaySound() {
		return nPlaySound;
	}

	public static void setNotificationPlaySound(boolean value) {
		nPlaySound = value;
	}

	// Notification Play Sound
	public static boolean getNotificationVibrate() {
		return nVibrate;
	}

	public static void setNotificationVibrate(boolean value) {
		nVibrate = value;
	}

	// Notification Show Light
	public static boolean getNotificationShowLight() {
		return nShowLight;
	}

	public static void setNotificationShowLight(boolean value) {
		nShowLight = value;
	}

	// Notification Auto Cancel
	public static boolean getNotificationAutoCancel() {
		return nAutoCancel;
	}

	public static void setNotificationAutoCancel(boolean value) {
		nAutoCancel = value;
	}

	// widgetBackground
	public static boolean getNotificationNoClear() {
		return nNoClear;
	}

	public static void setNotificationNoClear(boolean value) {
		nNoClear = value;
	}

	public static void getPreferences(Context context) {

		String s = null;
		SharedPreferences prefs = PreferenceManager
				.getDefaultSharedPreferences(context);

		// Widget
		String c = prefs.getString(WIDGET_ITEM_COUNT_PORTRAIT, ""
				+ getWidgetItemCountPortrait());
		setWidgetItemCountPortrait(Integer.valueOf(c));

		c = prefs.getString(WIDGET_ITEM_COUNT_LANDSCAPE, ""
				+ getWidgetItemCountLandscape());
		setWidgetItemCountLandscape(Integer.valueOf(c));

		s = prefs.getString(THEME, sBlackTheme);
		if (s.equals(sBlackTheme)) {
			Theme = ScreenTheme.THEME_BLACK;

		} else if (s.equals(sLightTheme)) {
			Theme = ScreenTheme.THEME_LIGHT;
		}

		showWidgetBackground = prefs.getBoolean(SHOW_WIDGET_BACKGROUND,
				showWidgetBackground);

		// Notification
		setNotificationEnable(prefs.getBoolean(NOTIFICATION_ENABLE,
				getNotificationEnable()));

		setNotificationShowLight(prefs.getBoolean(NOTIFICATION_SHOW_LIGHT,
				getNotificationShowLight()));

		setNotificationPlaySound(prefs.getBoolean(NOTIFICATION_PLAY_SOUND,
				getNotificationPlaySound()));

		setNotificationVibrate(prefs.getBoolean(NOTIFICATION_VIBRATE,
				getNotificationVibrate()));

		setNotificationAutoCancel(prefs.getBoolean(NOTIFICATION_AUTO_CANCEL,
				getNotificationAutoCancel()));

		setNotificationNoClear(prefs.getBoolean(NOTIFICATION_NO_CLEAR,
				getNotificationNoClear()));

		// Equalizer = prefs.getBoolean(EQUALIZER, Equalizer);
		// FastScroll = prefs.getBoolean(FAST_SCROLL, FastScroll);
		// s = prefs.getString(FONT_SIZE, "" + FontSize);
		// FontSize = Integer.valueOf(s);
		// s = prefs.getString(LINE_SPACING, "" + LineSpacing);
		// LineSpacing = Integer.valueOf(s);

		// ShowWhenLocked = prefs.getBoolean(SHOW_WHEN_LOCKED, ShowWhenLocked);
		// KeepNotification = prefs
		// .getBoolean(KEEP_NOTIFICATION, KeepNotification);

		// Files and Folders
		// ShowFolderSize = prefs.getBoolean(SHOW_FOLDER_SIZE, ShowFolderSize);
		// CountFolderElements = prefs.getBoolean(COUNT_FOLDER_ELEMENTS,
		// CountFolderElements);

		// cbTaskMode = Integer.parseInt(prefs.getString("task_mode", "1"));

		// HomeStorage = StorageType.fromInteger(prefs.getInt(HOME_STORAGE,
		// StorageType.toInteger(HomeStorage)));
		// HomeFolder = CategoryFolder.fromInteger(prefs.getInt(HOME_FOLDER,
		// CategoryFolder.toInteger(HomeFolder)));

	}

	public static int getCurrentTheme() {
		int themeId = 0;

		switch (Theme) {
		case THEME_BLACK:
			themeId = R.style.ThemeBlack;
			break;

		case THEME_LIGHT:
			themeId = R.style.ThemeLight;
			break;
		}

		return themeId;
	}
}
